local skel = fk.CreateSkill {
  name = "lb__yanxi",
  tags = { Skill.Compulsory }
}

Fk:loadTranslationTable {
  ["lb__yanxi"] = "焰嬉",
  --[":lb__yanxi"] = "<b>锁定技</b>，每回合首张红【杀】被使用后，若场上有体力值不为1且小于区域内牌数的角色，你对这些角色各造成1点火焰伤害，否则你摸两张牌。",
  --9.12
  [":lb__yanxi"] = "<b>锁定技</b>，每回合首张红【杀】被使用后，若场上存在体力值小于区域内牌数且体力值不为1的角色，你对这些角色各造成1点火焰伤害；若不存在或对你造成伤害，你摸三张牌。",


  ["#lb__yanxi"] = "焰嬉：令一名其他角色与你各摸一张牌",

  ["$lb__yanxi1"] = "我来了…嘿嘿…我又走咯~",
  ["$lb__yanxi2"] = "嘿嘿…没想到吧~",
  ["$lb__yanxi3"] = "哈！虎克来捣蛋！~",
}

skel:addEffect(fk.CardUseFinished, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and data.card.color == Card.Red and data.card.trueName == "slash" then
      local t = table.filter(player.room:getAlivePlayers(), function(p)
        return p.hp ~= 1 and (p.hp < #p:getCardIds("hej"))
      end)
      event:setCostData(self, { tos = t })
      local use_events = player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(e)
        local use = e.data
        return use.card.color == Card.Red and use.card.trueName == "slash"
      end, Player.HistoryTurn)
      return #use_events == 1 and use_events[1].data == data
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local tos = event:getCostData(self).tos
    if #tos == 0 then
      player:drawCards(3, skel.name)
    else
      for _, to in ipairs(tos) do
        if not to.dead then
          room:damage({
            from = player,
            to = to,
            damage = 1,
            damageType = fk.FireDamage,
            skillName = skel.name,
          })
          if player == to and not player.dead then
            player:drawCards(3, skel.name)
          end
        end
      end
    end
  end,
})

return skel
